set more off

use "Analysis Data/table1_3_data.dta", clear

foreach var of varlist voteshare_vb_2009 lit_pc scst_pc rural_pc {
gen treat_`var' = treat*`var'
}

replace station_id2 = -1*_n if station_id2==-9
replace station_id3 = -1000*_n if station_id3==-9

eststo clear
eststo: clus_nway reg turnoutrate_2014 turnoutrate_2009 poll_date? treat voteshare_vb_2009 treat_voteshare_vb_2009 [aweight=wgt_treat], cluster(station_id1 station_id2 station_id3)

eststo: clus_nway reg turnoutrate_2014 turnoutrate_2009 poll_date? treat lit_pc treat_lit_pc [aweight=wgt_treat], cluster(station_id1 station_id2 station_id3)

eststo: clus_nway reg turnoutrate_2014 turnoutrate_2009 poll_date? treat scst_pc treat_scst_pc [aweight=wgt_treat], cluster(station_id1 station_id2 station_id3)

eststo: clus_nway reg turnoutrate_2014 turnoutrate_2009 poll_date? treat rural_pc treat_rural_pc [aweight=wgt_treat], cluster(station_id1 station_id2 station_id3)

esttab, keep(treat voteshare_vb_2009 treat_voteshare_vb_2009 lit_pc treat_lit_pc scst_pc treat_scst_pc rural_pc treat_rural_pc)  ///
wrap cells(b(fmt(2)) se(par fmt(2)) p(fmt(2))) collabel(none) label stats(r2 N, fmt(2 0) labels("$R^2$" "Obs."))
